home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Magazine Collection 2001
/
Delphi Magazine Collection 20001 (2001).iso
/
DISKS
/
ISSUE18
/
SURVIVE
/
FMMAIN.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-12-06
|
4KB
|
130 lines
unit fmMain;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Menus, Grids, DBGrids, DB,
DBTables, ComCtrls;
type
TfrmMain = class(TForm)
mnuMain: TMainMenu;
ApplicationLoginItem: TMenuItem;
ApplicationLogoutItem: TMenuItem;
ApplicationChangePasswordItem: TMenuItem;
ApplicationExitItem: TMenuItem;
StatusLine: TStatusBar;
ApplicationMenu: TMenuItem;
ExitMenu: TMenuItem;
dbAppMain: TDatabase;
tblAuditTrail: TTable;
dsAuditTrail: TDataSource;
grdAuditTrail: TDBGrid;
procedure ExitMenuClick(Sender: TObject);
procedure ApplicationLoginItemClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure ApplicationLogoutItemClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ApplicationChangePasswordItemClick(Sender: TObject);
public
procedure LoginManagerLogin(Sender: TObject; Username: string; Password: string);
procedure LoginManagerLogout(Sender: TObject);
procedure LoginManagerBadLogin(Sender: TObject);
procedure LoginManagerPasswordExpired(Sender: TObject; var Cancel: Boolean);
end;
var
frmMain: TfrmMain;
implementation
uses
fmLogin, fmPasswd, Login;
{$R *.DFM}
procedure TfrmMain.LoginManagerLogin(Sender: TObject; Username: string; Password: string);
begin
StatusLine.Panels[0].Text := 'Username: ' + LoginManager.Username;
StatusLine.Panels[1].Text := LoginManager.UserFullName;
StatusLine.Panels[2].Text := 'Connected to ' +
LoginManager.ServerName + '\' + LoginManager.DatabaseName;
tblAuditTrail.Open;
grdAuditTrail.Visible := True;
ApplicationLogoutItem.Enabled := True;
ApplicationChangePasswordItem.Enabled := True;
end;
procedure TfrmMain.LoginManagerLogout(Sender: TObject);
begin
StatusLine.Panels[0].Text := 'No User';
StatusLine.Panels[1].Text := '';
StatusLine.Panels[2].Text := 'Not Connected';
StatusLine.Refresh;
ApplicationLogoutItem.Enabled := False;
ApplicationChangePasswordItem.Enabled := False;
grdAuditTrail.Visible := False;
end;
procedure TfrmMain.LoginManagerBadLogin(Sender: TObject);
begin
ShowMessage('That was a bad login. Naughty, naughty.');
end;
procedure TfrmMain.LoginManagerPasswordExpired(Sender: TObject;
var Cancel: Boolean);
begin
Cancel := LaunchPasswordExpiredDialog <> mrOK;
end;
procedure TfrmMain.FormCreate(Sender: TObject);
begin
{ Register the LoginManager component }
with LoginManager do
begin
ApplicationID := 1;
MainDB := dbAppMain;
(* ApplicationDBs.Add(dbPubs);*)
OnLogin := LoginManagerLogin;
OnLogout := LoginManagerLogout;
OnBadLogin := LoginManagerBadLogin;
OnPasswordExpired := LoginManagerPasswordExpired;
end;
end;
procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
LoginManager.Logout;
end;
procedure TfrmMain.ApplicationLoginItemClick(Sender: TObject);
var
Username, Password, Server, Database: string;
begin
if LaunchLoginDialog(Username, Password, Server, Database) = mrOK then
LoginManager.Login(Username, Password, Server, Database);
end;
procedure TfrmMain.ApplicationLogoutItemClick(Sender: TObject);
begin
LoginManager.Logout;
end;
procedure TfrmMain.ApplicationChangePasswordItemClick(Sender: TObject);
begin
LaunchChangePasswordDialog;
tblAuditTrail.Open;
end;
procedure TfrmMain.ExitMenuClick(Sender: TObject);
begin
Close;
end;
end.